﻿<Page x:Class="WpfBinding.CollectionViewTest"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      mc:Ignorable="d" 
      d:DesignHeight="368" d:DesignWidth="733"
	Title="CollectionViewTest">
    <Canvas>
 
        <ListBox Canvas.Left="12" Canvas.Top="47" Height="142" Name="listBox1" Width="259"  >
            <ListBox.ItemTemplate>
                <DataTemplate  >
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding Age}"  Width="100"/>
                        <TextBlock Text="{Binding City}" />
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <ListBox.GroupStyle>
                <GroupStyle>
                    <!--<GroupStyle.HeaderTemplate>
                        <DataTemplate>
                            <TextBlock FontWeight="Bold" Text="{Binding Name}" />
                        </DataTemplate>
                    </GroupStyle.HeaderTemplate>-->
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template" >
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander BorderBrush="Silver" BorderThickness="1">
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <TextBlock Text="{Binding Name}"  Width="100"/>
                                                    <TextBlock Text="{Binding ItemCount}" />
                                                </StackPanel>
                                            </Expander.Header>
                                            <Expander.Content>
                                                <ItemsPresenter />
                                            </Expander.Content>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </ListBox.GroupStyle>
        </ListBox>
        <Button Canvas.Left="12" Canvas.Top="12" Content="Sort" Height="23" Name="btnSort" Width="75" Click="btnSort_Click" />
        <Button Canvas.Left="101" Canvas.Top="12" Content="Group" Height="23" Name="button1" Width="75" Click="button1_Click" />
        <Button Canvas.Left="185" Canvas.Top="12" Content="Filter" Height="23" Name="btnFilter" Width="75" Click="btnFilter_Click" />
        <Button Canvas.Left="266" Canvas.Top="12" Content="Next" Height="23" Name="button2" Width="45" Click="button2_Click" />
        <Button Canvas.Left="317" Canvas.Top="12" Content="Previous" Height="23" Name="button3" Width="60" Click="button3_Click" />
    </Canvas>
</Page>
